<?php
namespace App\Module\Admin\Controller;

use App\Common\Controller\AbstractController;
use App\Module\Admin\Request\Activity\CreateRequest;
use App\Module\Admin\Request\Activity\UpdateRequest;
use App\Module\Admin\Service\ActivityService;
use Hyperf\Di\Annotation\Inject;

class ActivityController extends AbstractController{

    /**
     * @Inject()
     * @var ActivityService $activityService
     */
    private $activityService;

    public function search(){
        $pagesize = $this->request->input("pagesize");

        return $this->response->json($this->activityService->search($pagesize));
    }

    public function add(CreateRequest $request){
        return $this->response->json($this->activityService->create($request));
    }

    public function getById(int $id){
        return $this->response->json($this->activityService->getById($id));
    }

    public function edit(UpdateRequest $request,int $id){
        return $this->response->json($this->activityService->update($request,$id));
    }

    public function show(int $id){
        return $this->response->json($this->activityService->show($id));
    }

    public function finish(int $id){
        return $this->response->json($this->activityService->finish($id));
    }
}